--
--    Health Organizer (http://sourceforge.net/projects/hor/,
--                      http://hor.sourceforge.net/)
--    Copyright (C) 2015-2016  Andrea Urbani ( matfanjol@users.sf.net )
--
--    This program is free software: you can redistribute it and/or modify
--    it under the terms of the GNU General Public License as published by
--    the Free Software Foundation, either version 3 of the License, or
--    (at your option) any later version.
--
--    This program is distributed in the hope that it will be useful,
--    but WITHOUT ANY WARRANTY; without even the implied warranty of
--    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
--    GNU General Public License for more details.
--
--    You should have received a copy of the GNU General Public License
--    along with this program.  If not, see <http://www.gnu.org/licenses/>.
--
-- PostgreSQL database dump
--

SET statement_timeout = 0;
SET lock_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;

--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--

CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;


--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--


SET search_path = public, pg_catalog;

SET default_tablespace = '';

SET default_with_oids = false;

--
-- Name: tAdmissions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tAdmissions" (
    "ID" integer NOT NULL,
    "ID_Hospital" integer NOT NULL,
    "ID_HospitalWard" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "FromDate" timestamp without time zone NOT NULL,
    "ToDate" timestamp without time zone,
    "Note" text,
    "ID_Document" integer
);


--
-- Name: tAdmissions_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tAdmissions_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tAdmissions_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tAdmissions_ID_seq" OWNED BY "tAdmissions"."ID";


--
-- Name: tAllergies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tAllergies" (
    "ID_Patient" integer NOT NULL,
    "ID_AllergyTo" integer NOT NULL,
    "ID_AllergyReactions" integer NOT NULL,
    "Note" text
);


--
-- Name: tAllergiesReactions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tAllergiesReactions" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tAllergiesReactions"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tAllergiesReactions"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tAllergiesReactions_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tAllergiesReactions_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tAllergiesReactions_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tAllergiesReactions_ID_seq" OWNED BY "tAllergiesReactions"."ID";


--
-- Name: tAllergiesTo; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tAllergiesTo" (
    "ID" integer NOT NULL,
    "Name" character(45) NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tAllergiesTo"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tAllergiesTo"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tAllergiesTo_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tAllergiesTo_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tAllergiesTo_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tAllergiesTo_ID_seq" OWNED BY "tAllergiesTo"."ID";


--
-- Name: tContactsTypes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tContactsTypes" (
    "ID" integer NOT NULL,
    "Name" character varying(10) NOT NULL,
    "Icon" integer,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tContactsTypes"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tContactsTypes"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tContactsTypes_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tContactsTypes_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tContactsTypes_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tContactsTypes_ID_seq" OWNED BY "tContactsTypes"."ID";


--
-- Name: tCountries; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountries" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL,
    "SubGroup1Name" character varying(45),
    "SubGroup2Name" character varying(45),
    "SubGroup3Name" character varying(45)
);


--
-- Name: COLUMN "tCountries"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountries"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: COLUMN "tCountries"."SubGroup1Name"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountries"."SubGroup1Name" IS 'If it is not empty, it means the sub group 1 is used with the given name.';


--
-- Name: COLUMN "tCountries"."SubGroup2Name"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountries"."SubGroup2Name" IS 'If it is not empty, it means the sub group 2 is used with the given name.';


--
-- Name: COLUMN "tCountries"."SubGroup3Name"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountries"."SubGroup3Name" IS 'If it is not empty, it means the sub group 3 is used with the given name.';


--
-- Name: tCountriesCities; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountriesCities" (
    "ID_Country" integer NOT NULL,
    "ID_SubGroup1" integer NOT NULL,
    "ID_SubGroup2" integer NOT NULL,
    "ID_SubGroup3" integer NOT NULL,
    "ID_City" integer NOT NULL,
    "Name" character varying(45),
    "Code" character varying(15),
    "ZIPCode" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tCountriesCities"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountriesCities"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tCountriesCitiesAddresses; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountriesCitiesAddresses" (
    "ID_Country" integer NOT NULL,
    "ID_SubGroup1" integer NOT NULL,
    "ID_SubGroup2" integer NOT NULL,
    "ID_SubGroup3" integer NOT NULL,
    "ID_City" integer NOT NULL,
    "ID_Address" integer NOT NULL,
    "Name" character varying(45),
    "Code" character varying(15),
    "ZIPCode" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tCountriesCitiesAddresses"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountriesCitiesAddresses"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tCountriesSubGroup1; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountriesSubGroup1" (
    "ID_Country" integer NOT NULL,
    "ID_SubGroup1" integer NOT NULL,
    "Name" character varying(45),
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tCountriesSubGroup1"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountriesSubGroup1"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tCountriesSubGroup2; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountriesSubGroup2" (
    "ID_Country" integer NOT NULL,
    "ID_SubGroup1" integer NOT NULL,
    "ID_SubGroup2" integer NOT NULL,
    "Name" character varying(45),
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tCountriesSubGroup2"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountriesSubGroup2"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tCountriesSubGroup3; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tCountriesSubGroup3" (
    "ID_Country" integer NOT NULL,
    "ID_SubGroup1" integer NOT NULL,
    "ID_SubGroup2" integer NOT NULL,
    "ID_SubGroup3" integer NOT NULL,
    "Name" character varying(45),
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tCountriesSubGroup3"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tCountriesSubGroup3"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tCountries_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tCountries_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tCountries_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tCountries_ID_seq" OWNED BY "tCountries"."ID";


--
-- Name: tDoctors; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDoctors" (
    "ID_Person" integer NOT NULL
);


--
-- Name: tDoctorsTypes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDoctorsTypes" (
    "ID_Person" integer NOT NULL,
    "ID_DoctorTypeCategory" integer NOT NULL
);


--
-- Name: tDoctorsTypesCategories; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDoctorsTypesCategories" (
    "ID" integer NOT NULL,
    "Name" character varying(15) NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tDoctorsTypesCategories"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tDoctorsTypesCategories"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tDoctorsTypesCategories_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDoctorsTypesCategories_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDoctorsTypesCategories_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDoctorsTypesCategories_ID_seq" OWNED BY "tDoctorsTypesCategories"."ID";


--
-- Name: tDocuments; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDocuments" (
    "ID" integer NOT NULL,
    "Date" timestamp without time zone DEFAULT now() NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Note" text,
    "Link" text,
    "ID_Person" integer NOT NULL
);


--
-- Name: tDocumentsFiles; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDocumentsFiles" (
    "ID_Document" integer NOT NULL,
    "ID_File" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "FileName" character varying(260) NOT NULL,
    "Link" text,
    "Note" text,
    "Picture" bytea,
    "Content" bytea,
    "FileSize" bigint
);


--
-- Name: tDocuments_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDocuments_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDocuments_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDocuments_ID_seq" OWNED BY "tDocuments"."ID";


--
-- Name: tDrugs; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDrugs" (
    "ID" integer NOT NULL,
    "ID_DrugName" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "Note" text,
    "Quantity" real NOT NULL
);


--
-- Name: tDrugsCompanies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDrugsCompanies" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Note" text,
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tDrugsCompanies"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tDrugsCompanies"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tDrugsCompanies_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDrugsCompanies_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDrugsCompanies_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDrugsCompanies_ID_seq" OWNED BY "tDrugsCompanies"."ID";


--
-- Name: tDrugsNames; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDrugsNames" (
    "ID" integer NOT NULL,
    "ID_Company" integer NOT NULL,
    "Name" character varying(100) NOT NULL,
    "Note" text,
    "Code" character varying(15),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tDrugsNames"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tDrugsNames"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tDrugsNames_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDrugsNames_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDrugsNames_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDrugsNames_ID_seq" OWNED BY "tDrugsNames"."ID";


--
-- Name: tDrugsPrescriptions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tDrugsPrescriptions" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "ID_DrugName" integer NOT NULL,
    "When" timestamp without time zone NOT NULL,
    "Quantity" real NOT NULL,
    "StartDate" timestamp without time zone,
    "EndDate" timestamp without time zone,
    "ID_Document" integer
);


--
-- Name: tDrugsPrescriptions_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDrugsPrescriptions_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDrugsPrescriptions_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDrugsPrescriptions_ID_seq" OWNED BY "tDrugsPrescriptions"."ID";


--
-- Name: tDrugs_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tDrugs_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tDrugs_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tDrugs_ID_seq" OWNED BY "tDrugs"."ID";


--
-- Name: tExaminations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminations" (
    "ID" integer NOT NULL,
    "ID_ExaminationName" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "ID_Hospital" integer,
    "Note" text,
    "ID_HospitalWard" integer,
    "ID_Prescription" integer,
    "ID_Document" integer,
    "ResultDate" timestamp without time zone,
    "ResultTaken" boolean DEFAULT false NOT NULL,
    "Booked" boolean DEFAULT false NOT NULL,
    "ID_Doctor" integer
);


--
-- Name: COLUMN "tExaminations"."ResultDate"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tExaminations"."ResultDate" IS 'From when the results of this examination will be available';


--
-- Name: COLUMN "tExaminations"."ResultTaken"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tExaminations"."ResultTaken" IS 'True if the result was taken, otherwise false (in this last case an appointment to take the result will be available from the ResultDate date)';


--
-- Name: tExaminationsDateChanges; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminationsDateChanges" (
    "ID_Examination" integer NOT NULL,
    "DateOfChange" timestamp without time zone NOT NULL,
    "OriginalData" timestamp without time zone NOT NULL,
    "NewDate" timestamp without time zone NOT NULL,
    "ID_Document" integer,
    "Note" text
);


--
-- Name: tExaminationsDoctors; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminationsDoctors" (
    "ID_Examination" integer NOT NULL,
    "ID_Doctor" integer NOT NULL
);


--
-- Name: tExaminationsNames; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminationsNames" (
    "ID" integer NOT NULL,
    "Name" character varying(384) NOT NULL,
    "Note" text,
    "Code" character varying(18),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL,
    "System" boolean DEFAULT false NOT NULL,
    "ID_ExaminationNameCategory" integer,
    "Price" real
);


--
-- Name: COLUMN "tExaminationsNames"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tExaminationsNames"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: COLUMN "tExaminationsNames"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tExaminationsNames"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tExaminationsNamesCategories; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminationsNamesCategories" (
    "ID" integer NOT NULL,
    "Name" character varying(55) NOT NULL,
    "Note" text,
    "Code" character varying(18),
    "Origin" character varying(15)
);


--
-- Name: COLUMN "tExaminationsNamesCategories"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tExaminationsNamesCategories"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tExaminationsNamesCategories_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tExaminationsNamesCategories_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tExaminationsNamesCategories_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tExaminationsNamesCategories_ID_seq" OWNED BY "tExaminationsNamesCategories"."ID";


--
-- Name: tExaminationsNames_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tExaminationsNames_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tExaminationsNames_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tExaminationsNames_ID_seq" OWNED BY "tExaminationsNames"."ID";


--
-- Name: tExaminationsProblems; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExaminationsProblems" (
    "ID_Examination" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "ID_Problem" integer NOT NULL,
    "ID_Position" integer NOT NULL
);


--
-- Name: tExaminations_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tExaminations_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tExaminations_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tExaminations_ID_seq" OWNED BY "tExaminations"."ID";


--
-- Name: tExemption; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tExemption" (
    "ID" integer NOT NULL,
    "ID_Person" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "StartDate" date,
    "EndDate" date,
    "ID_Document" integer NOT NULL
);


--
-- Name: tExemption_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tExemption_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tExemption_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tExemption_ID_seq" OWNED BY "tExemption"."ID";


--
-- Name: tHospitals; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitals" (
    "ID" integer NOT NULL,
    "Name" character varying(35) NOT NULL,
    "Note" text,
    "ID_Country" integer,
    "ID_SubGroup1" integer,
    "ID_SubGroup2" integer,
    "ID_SubGroup3" integer,
    "ID_City" integer,
    "ID_Address" integer,
    "Number" character varying(45),
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tHospitals"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tHospitals"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tHospitalsContacts; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitalsContacts" (
    "ID_Hospital" integer NOT NULL,
    "ID_Contact" integer NOT NULL,
    "ID_ContactType" integer NOT NULL,
    "Contact" character varying(45) NOT NULL,
    "Note" text
);


--
-- Name: tHospitalsParking; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitalsParking" (
    "ID_Hospital" integer NOT NULL,
    "ID_Parking" integer NOT NULL,
    "ID_ParkingType" integer NOT NULL,
    "Address" character varying(50),
    "Coordinates" text,
    "Note" text,
    "Origin" character varying(15)
);


--
-- Name: COLUMN "tHospitalsParking"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tHospitalsParking"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tHospitalsParkingTypes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitalsParkingTypes" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL
);


--
-- Name: tHospitalsParkingTypes_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tHospitalsParkingTypes_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tHospitalsParkingTypes_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tHospitalsParkingTypes_ID_seq" OWNED BY "tHospitalsParkingTypes"."ID";


--
-- Name: tHospitalsWards; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitalsWards" (
    "ID_Hospital" integer NOT NULL,
    "ID_Ward" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Note" text,
    "Origin" character varying(15)
);


--
-- Name: COLUMN "tHospitalsWards"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tHospitalsWards"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: tHospitalsWardsContacts; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tHospitalsWardsContacts" (
    "ID_Hospital" integer NOT NULL,
    "ID_Ward" integer NOT NULL,
    "ID_Contact" integer NOT NULL,
    "ID_ContactType" integer NOT NULL,
    "Contact" character varying(45) NOT NULL,
    "Note" text,
    "Origin" character varying(15)
);


--
-- Name: tHospitals_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tHospitals_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tHospitals_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tHospitals_ID_seq" OWNED BY "tHospitals"."ID";


--
-- Name: tLanguages; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tLanguages" (
    "Language" character varying(5) NOT NULL,
    "Date" character varying(11) NOT NULL,
    "Time" character varying(11) NOT NULL,
    "Weight" integer NOT NULL
);


--
-- Name: tLife; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tLife" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "Note" text
);


--
-- Name: tLifeDetails; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tLifeDetails" (
    "ID_Life" integer NOT NULL,
    "ID_LifeType" integer NOT NULL,
    "Quantity" real NOT NULL,
    "Note" text
);


--
-- Name: tLifeTypes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tLifeTypes" (
    "ID" integer NOT NULL,
    "ID_LifeTypeCategory" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "ID_MeasureUnit" integer NOT NULL,
    "DefaultQuantity" real,
    "Note" text
);


--
-- Name: tLifeTypesCategories; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tLifeTypesCategories" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Icon" integer,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tLifeTypesCategories"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tLifeTypesCategories"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tLifeTypesCategories_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tLifeTypesCategories_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tLifeTypesCategories_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tLifeTypesCategories_ID_seq" OWNED BY "tLifeTypesCategories"."ID";


--
-- Name: tLifeTypes_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tLifeTypes_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tLifeTypes_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tLifeTypes_ID_seq" OWNED BY "tLifeTypes"."ID";


--
-- Name: tLife_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tLife_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tLife_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tLife_ID_seq" OWNED BY "tLife"."ID";


--
-- Name: tMeasurements; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tMeasurements" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "Note" text
);


--
-- Name: tMeasurementsDetails; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tMeasurementsDetails" (
    "ID_Measurement" integer NOT NULL,
    "ID_MeasurementType" integer NOT NULL,
    "Quantity" real NOT NULL,
    "Note" text
);


--
-- Name: tMeasurementsTypes; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tMeasurementsTypes" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "ID_MeasureUnit" integer NOT NULL,
    "Note" text,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tMeasurementsTypes"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tMeasurementsTypes"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tMeasurementsTypes_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tMeasurementsTypes_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tMeasurementsTypes_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tMeasurementsTypes_ID_seq" OWNED BY "tMeasurementsTypes"."ID";


--
-- Name: tMeasurementsUnits; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tMeasurementsUnits" (
    "ID" integer NOT NULL,
    "Name" character varying(10) NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: TABLE "tMeasurementsUnits"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON TABLE "tMeasurementsUnits" IS 'It stores all the unit of measurements';


--
-- Name: COLUMN "tMeasurementsUnits"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tMeasurementsUnits"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tMeasurementsUnits_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tMeasurementsUnits_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tMeasurementsUnits_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tMeasurementsUnits_ID_seq" OWNED BY "tMeasurementsUnits"."ID";


--
-- Name: tMeasurements_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tMeasurements_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tMeasurements_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tMeasurements_ID_seq" OWNED BY "tMeasurements"."ID";


--
-- Name: tPathologies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPathologies" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "Origin" character varying(15),
    "Expired" boolean DEFAULT false NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tPathologies"."Origin"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tPathologies"."Origin" IS 'It will be used to know if this entry comes from an automation import and, if yes (field not empty), from which one.';


--
-- Name: COLUMN "tPathologies"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tPathologies"."System" IS 'It indicates if this entry was created by the "system" (the software).



If yes, the user can''t change/delete it.';


--
-- Name: tPathologies_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tPathologies_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tPathologies_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tPathologies_ID_seq" OWNED BY "tPathologies"."ID";


--
-- Name: tPatients; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPatients" (
    "ID_Person" integer NOT NULL,
    "ID_Doctor" integer,
    "BloodGroup" character(2),
    "BloodRh" character(1),
    "NotesToWriteIntoTheUsbStick" text,
    CONSTRAINT "ck_tPatients_BloodGroup" CHECK (("BloodGroup" = ANY (ARRAY['A'::bpchar, 'B'::bpchar, 'AB'::bpchar, '0'::bpchar]))),
    CONSTRAINT "ck_tPatients_BloodRh" CHECK (("BloodRh" = ANY (ARRAY['+'::bpchar, '-'::bpchar])))
);


--
-- Name: tPatientsPathologies; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPatientsPathologies" (
    "ID_Person" integer NOT NULL,
    "ID_Pathology" integer NOT NULL,
    "StartDate" date,
    "EndDate" date,
    "Note" text
);


--
-- Name: tPersons; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPersons" (
    "ID" integer NOT NULL,
    "Name" character varying(35) NOT NULL,
    "Surname" character varying(35),
    "Sex" character(1) NOT NULL,
    "Note" text,
    "ID_Country" integer,
    "ID_SubGroup1" integer,
    "ID_SubGroup2" integer,
    "ID_SubGroup3" integer,
    "ID_City" integer,
    "ID_Address" integer,
    "Number" character varying(45),
    "Birth_Day" date,
    "Birth_ID_Country" integer,
    "Birth_ID_SubGroup1" integer,
    "Birth_ID_SubGroup2" integer,
    "Birth_ID_SubGroup3" integer,
    "Birth_ID_City" integer,
    "Dead_Day" date,
    CONSTRAINT "ck_tPersons_Sex" CHECK (("Sex" = ANY (ARRAY['M'::bpchar, 'F'::bpchar, 'I'::bpchar, 'T'::bpchar])))
);


--
-- Name: COLUMN "tPersons"."Sex"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tPersons"."Sex" IS 'M=Male F=Female I=Intersex T=Transexual';


--
-- Name: tPersonsContacts; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPersonsContacts" (
    "ID_Person" integer NOT NULL,
    "ID_Contact" integer NOT NULL,
    "ID_ContactType" integer NOT NULL,
    "Contact" character varying(45) NOT NULL,
    "Note" text
);


--
-- Name: tPersons_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tPersons_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tPersons_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tPersons_ID_seq" OWNED BY "tPersons"."ID";


--
-- Name: tPrescriptions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tPrescriptions" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "ID_ExaminationName" integer NOT NULL,
    "ID_Doctor" integer NOT NULL,
    "Date" timestamp without time zone NOT NULL,
    "Priority" character(1),
    "Note" text,
    "ID_Document" integer
);


--
-- Name: tPrescriptions_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tPrescriptions_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tPrescriptions_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tPrescriptions_ID_seq" OWNED BY "tPrescriptions"."ID";


--
-- Name: tProblems; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tProblems" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "StartDate" date,
    "EndDate" date,
    "ID_Document" integer,
    "ID_Pathology" integer,
    "Note" text
);


--
-- Name: tProblemsPositions; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tProblemsPositions" (
    "ID_Problem" integer NOT NULL,
    "ID_Position" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "ID_Document" integer
);


--
-- Name: tProblems_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tProblems_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tProblems_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tProblems_ID_seq" OWNED BY "tProblems"."ID";


--
-- Name: tSettings; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tSettings" (
    "ID" integer NOT NULL,
    "DbVersion" smallint DEFAULT 1 NOT NULL,
    "CountryName" character varying(45),
    "CountryPhoneCode" character varying(5),
    "CountryCode" character varying(15)
);


--
-- Name: tSettings_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tSettings_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tSettings_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tSettings_ID_seq" OWNED BY "tSettings"."ID";


--
-- Name: tVaccinations; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tVaccinations" (
    "ID" integer NOT NULL,
    "ID_Patient" integer NOT NULL,
    "ID_VaccinationStep" integer NOT NULL,
    "Date" timestamp without time zone DEFAULT now() NOT NULL,
    "Note" text
);


--
-- Name: tVaccinationsNames; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tVaccinationsNames" (
    "ID" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tVaccinationsNames"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tVaccinationsNames"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tVaccinationsNames_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tVaccinationsNames_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tVaccinationsNames_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tVaccinationsNames_ID_seq" OWNED BY "tVaccinationsNames"."ID";


--
-- Name: tVaccinationsSteps; Type: TABLE; Schema: public; Owner: -; Tablespace: 
--

CREATE TABLE "tVaccinationsSteps" (
    "ID" integer NOT NULL,
    "ID_VaccinationName" integer NOT NULL,
    "Name" character varying(45) NOT NULL,
    "ID_NextVaccinationStep" integer,
    "NextVaccinationStepAfterDays" integer,
    "System" boolean DEFAULT false NOT NULL
);


--
-- Name: COLUMN "tVaccinationsSteps"."System"; Type: COMMENT; Schema: public; Owner: -
--

COMMENT ON COLUMN "tVaccinationsSteps"."System" IS 'It indicates if this entry was created by the "system" (the software). If yes, the user can''t change/delete it.';


--
-- Name: tVaccinationsSteps_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tVaccinationsSteps_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tVaccinationsSteps_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tVaccinationsSteps_ID_seq" OWNED BY "tVaccinationsSteps"."ID";


--
-- Name: tVaccinations_ID_seq; Type: SEQUENCE; Schema: public; Owner: -
--

CREATE SEQUENCE "tVaccinations_ID_seq"
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;


--
-- Name: tVaccinations_ID_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
--

ALTER SEQUENCE "tVaccinations_ID_seq" OWNED BY "tVaccinations"."ID";


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAdmissions" ALTER COLUMN "ID" SET DEFAULT nextval('"tAdmissions_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAllergiesReactions" ALTER COLUMN "ID" SET DEFAULT nextval('"tAllergiesReactions_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAllergiesTo" ALTER COLUMN "ID" SET DEFAULT nextval('"tAllergiesTo_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tContactsTypes" ALTER COLUMN "ID" SET DEFAULT nextval('"tContactsTypes_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountries" ALTER COLUMN "ID" SET DEFAULT nextval('"tCountries_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDoctorsTypesCategories" ALTER COLUMN "ID" SET DEFAULT nextval('"tDoctorsTypesCategories_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDocuments" ALTER COLUMN "ID" SET DEFAULT nextval('"tDocuments_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugs" ALTER COLUMN "ID" SET DEFAULT nextval('"tDrugs_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsCompanies" ALTER COLUMN "ID" SET DEFAULT nextval('"tDrugsCompanies_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsNames" ALTER COLUMN "ID" SET DEFAULT nextval('"tDrugsNames_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsPrescriptions" ALTER COLUMN "ID" SET DEFAULT nextval('"tDrugsPrescriptions_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations" ALTER COLUMN "ID" SET DEFAULT nextval('"tExaminations_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsNames" ALTER COLUMN "ID" SET DEFAULT nextval('"tExaminationsNames_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsNamesCategories" ALTER COLUMN "ID" SET DEFAULT nextval('"tExaminationsNamesCategories_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExemption" ALTER COLUMN "ID" SET DEFAULT nextval('"tExemption_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitals" ALTER COLUMN "ID" SET DEFAULT nextval('"tHospitals_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsParkingTypes" ALTER COLUMN "ID" SET DEFAULT nextval('"tHospitalsParkingTypes_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLife" ALTER COLUMN "ID" SET DEFAULT nextval('"tLife_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeTypes" ALTER COLUMN "ID" SET DEFAULT nextval('"tLifeTypes_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeTypesCategories" ALTER COLUMN "ID" SET DEFAULT nextval('"tLifeTypesCategories_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurements" ALTER COLUMN "ID" SET DEFAULT nextval('"tMeasurements_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurementsTypes" ALTER COLUMN "ID" SET DEFAULT nextval('"tMeasurementsTypes_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurementsUnits" ALTER COLUMN "ID" SET DEFAULT nextval('"tMeasurementsUnits_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPathologies" ALTER COLUMN "ID" SET DEFAULT nextval('"tPathologies_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPersons" ALTER COLUMN "ID" SET DEFAULT nextval('"tPersons_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPrescriptions" ALTER COLUMN "ID" SET DEFAULT nextval('"tPrescriptions_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblems" ALTER COLUMN "ID" SET DEFAULT nextval('"tProblems_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tSettings" ALTER COLUMN "ID" SET DEFAULT nextval('"tSettings_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinations" ALTER COLUMN "ID" SET DEFAULT nextval('"tVaccinations_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinationsNames" ALTER COLUMN "ID" SET DEFAULT nextval('"tVaccinationsNames_ID_seq"'::regclass);


--
-- Name: ID; Type: DEFAULT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinationsSteps" ALTER COLUMN "ID" SET DEFAULT nextval('"tVaccinationsSteps_ID_seq"'::regclass);


--
-- Name: pk_tAdmissions; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tAdmissions"
    ADD CONSTRAINT "pk_tAdmissions" PRIMARY KEY ("ID");


--
-- Name: pk_tAllergies; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tAllergies"
    ADD CONSTRAINT "pk_tAllergies" PRIMARY KEY ("ID_Patient", "ID_AllergyTo");


--
-- Name: pk_tAllergiesReactions; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tAllergiesReactions"
    ADD CONSTRAINT "pk_tAllergiesReactions" PRIMARY KEY ("ID");


--
-- Name: pk_tAllergiesTo; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tAllergiesTo"
    ADD CONSTRAINT "pk_tAllergiesTo" PRIMARY KEY ("ID");


--
-- Name: pk_tContactsTypes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tContactsTypes"
    ADD CONSTRAINT "pk_tContactsTypes" PRIMARY KEY ("ID");


--
-- Name: pk_tCountries; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountries"
    ADD CONSTRAINT "pk_tCountries" PRIMARY KEY ("ID");


--
-- Name: pk_tCountriesCities; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountriesCities"
    ADD CONSTRAINT "pk_tCountriesCities" PRIMARY KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City");


--
-- Name: pk_tCountriesCitiesAddresses; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountriesCitiesAddresses"
    ADD CONSTRAINT "pk_tCountriesCitiesAddresses" PRIMARY KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City", "ID_Address");


--
-- Name: pk_tCountriesSubGroup1; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountriesSubGroup1"
    ADD CONSTRAINT "pk_tCountriesSubGroup1" PRIMARY KEY ("ID_Country", "ID_SubGroup1");


--
-- Name: pk_tCountriesSubGroup2; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountriesSubGroup2"
    ADD CONSTRAINT "pk_tCountriesSubGroup2" PRIMARY KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2");


--
-- Name: pk_tCountriesSubGroup3; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountriesSubGroup3"
    ADD CONSTRAINT "pk_tCountriesSubGroup3" PRIMARY KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3");


--
-- Name: pk_tDoctors; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDoctors"
    ADD CONSTRAINT "pk_tDoctors" PRIMARY KEY ("ID_Person");


--
-- Name: pk_tDoctorsTypes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDoctorsTypes"
    ADD CONSTRAINT "pk_tDoctorsTypes" PRIMARY KEY ("ID_Person", "ID_DoctorTypeCategory");


--
-- Name: pk_tDoctorsTypesCategories; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDoctorsTypesCategories"
    ADD CONSTRAINT "pk_tDoctorsTypesCategories" PRIMARY KEY ("ID");


--
-- Name: pk_tDocuments; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDocuments"
    ADD CONSTRAINT "pk_tDocuments" PRIMARY KEY ("ID");


--
-- Name: pk_tDocumentsFiles; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDocumentsFiles"
    ADD CONSTRAINT "pk_tDocumentsFiles" PRIMARY KEY ("ID_Document", "ID_File");


--
-- Name: pk_tDrugs; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugs"
    ADD CONSTRAINT "pk_tDrugs" PRIMARY KEY ("ID");


--
-- Name: pk_tDrugsCompanies; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugsCompanies"
    ADD CONSTRAINT "pk_tDrugsCompanies" PRIMARY KEY ("ID");


--
-- Name: pk_tDrugsNames; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugsNames"
    ADD CONSTRAINT "pk_tDrugsNames" PRIMARY KEY ("ID");


--
-- Name: pk_tDrugsPrescriptions; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugsPrescriptions"
    ADD CONSTRAINT "pk_tDrugsPrescriptions" PRIMARY KEY ("ID");


--
-- Name: pk_tExaminations; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "pk_tExaminations" PRIMARY KEY ("ID");


--
-- Name: pk_tExaminationsDateChanges; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsDateChanges"
    ADD CONSTRAINT "pk_tExaminationsDateChanges" PRIMARY KEY ("ID_Examination", "DateOfChange");


--
-- Name: pk_tExaminationsDoctors; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsDoctors"
    ADD CONSTRAINT "pk_tExaminationsDoctors" PRIMARY KEY ("ID_Examination", "ID_Doctor");


--
-- Name: pk_tExaminationsNames; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsNames"
    ADD CONSTRAINT "pk_tExaminationsNames" PRIMARY KEY ("ID");


--
-- Name: pk_tExaminationsNamesCategories; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsNamesCategories"
    ADD CONSTRAINT "pk_tExaminationsNamesCategories" PRIMARY KEY ("ID");


--
-- Name: pk_tExaminationsProblems; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsProblems"
    ADD CONSTRAINT "pk_tExaminationsProblems" PRIMARY KEY ("ID_Examination", "ID_Patient", "ID_Problem", "ID_Position");


--
-- Name: pk_tExemption; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExemption"
    ADD CONSTRAINT "pk_tExemption" PRIMARY KEY ("ID");


--
-- Name: pk_tHospitals; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitals"
    ADD CONSTRAINT "pk_tHospitals" PRIMARY KEY ("ID");


--
-- Name: pk_tHospitalsContacts; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitalsContacts"
    ADD CONSTRAINT "pk_tHospitalsContacts" PRIMARY KEY ("ID_Hospital", "ID_Contact");


--
-- Name: pk_tHospitalsParking; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitalsParking"
    ADD CONSTRAINT "pk_tHospitalsParking" PRIMARY KEY ("ID_Hospital", "ID_Parking");


--
-- Name: pk_tHospitalsParkingTypes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitalsParkingTypes"
    ADD CONSTRAINT "pk_tHospitalsParkingTypes" PRIMARY KEY ("ID");


--
-- Name: pk_tHospitalsWards; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitalsWards"
    ADD CONSTRAINT "pk_tHospitalsWards" PRIMARY KEY ("ID_Hospital", "ID_Ward");


--
-- Name: pk_tHospitalsWardsContacts; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tHospitalsWardsContacts"
    ADD CONSTRAINT "pk_tHospitalsWardsContacts" PRIMARY KEY ("ID_Hospital", "ID_Ward", "ID_Contact");


--
-- Name: pk_tLanguages; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tLanguages"
    ADD CONSTRAINT "pk_tLanguages" PRIMARY KEY ("Language");


--
-- Name: pk_tLife; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tLife"
    ADD CONSTRAINT "pk_tLife" PRIMARY KEY ("ID");


--
-- Name: pk_tLifeDetails; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tLifeDetails"
    ADD CONSTRAINT "pk_tLifeDetails" PRIMARY KEY ("ID_Life", "ID_LifeType");


--
-- Name: pk_tLifeTypes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tLifeTypes"
    ADD CONSTRAINT "pk_tLifeTypes" PRIMARY KEY ("ID");


--
-- Name: pk_tLifeTypesCategories; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tLifeTypesCategories"
    ADD CONSTRAINT "pk_tLifeTypesCategories" PRIMARY KEY ("ID");


--
-- Name: pk_tMeasurements; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tMeasurements"
    ADD CONSTRAINT "pk_tMeasurements" PRIMARY KEY ("ID");


--
-- Name: pk_tMeasurementsDetails; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tMeasurementsDetails"
    ADD CONSTRAINT "pk_tMeasurementsDetails" PRIMARY KEY ("ID_Measurement", "ID_MeasurementType");


--
-- Name: pk_tMeasurementsTypes; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tMeasurementsTypes"
    ADD CONSTRAINT "pk_tMeasurementsTypes" PRIMARY KEY ("ID");


--
-- Name: pk_tMeasurementsUnits; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tMeasurementsUnits"
    ADD CONSTRAINT "pk_tMeasurementsUnits" PRIMARY KEY ("ID");


--
-- Name: pk_tPathologies; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPathologies"
    ADD CONSTRAINT "pk_tPathologies" PRIMARY KEY ("ID");


--
-- Name: pk_tPatients; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPatients"
    ADD CONSTRAINT "pk_tPatients" PRIMARY KEY ("ID_Person");


--
-- Name: pk_tPatientsPathologies; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPatientsPathologies"
    ADD CONSTRAINT "pk_tPatientsPathologies" PRIMARY KEY ("ID_Person", "ID_Pathology");


--
-- Name: pk_tPersons; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPersons"
    ADD CONSTRAINT "pk_tPersons" PRIMARY KEY ("ID");


--
-- Name: pk_tPersonsContacts; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPersonsContacts"
    ADD CONSTRAINT "pk_tPersonsContacts" PRIMARY KEY ("ID_Person", "ID_Contact");


--
-- Name: pk_tPrescriptions; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tPrescriptions"
    ADD CONSTRAINT "pk_tPrescriptions" PRIMARY KEY ("ID");


--
-- Name: pk_tProblems; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tProblems"
    ADD CONSTRAINT "pk_tProblems" PRIMARY KEY ("ID");


--
-- Name: pk_tProblemstPositions; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tProblemsPositions"
    ADD CONSTRAINT "pk_tProblemstPositions" PRIMARY KEY ("ID_Problem", "ID_Position");


--
-- Name: pk_tSettings; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tSettings"
    ADD CONSTRAINT "pk_tSettings" PRIMARY KEY ("ID");


--
-- Name: pk_tVaccinations; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tVaccinations"
    ADD CONSTRAINT "pk_tVaccinations" PRIMARY KEY ("ID");


--
-- Name: pk_tVaccinationsNames; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tVaccinationsNames"
    ADD CONSTRAINT "pk_tVaccinationsNames" PRIMARY KEY ("ID");


--
-- Name: pk_tVaccinationsSteps; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tVaccinationsSteps"
    ADD CONSTRAINT "pk_tVaccinationsSteps" PRIMARY KEY ("ID");


--
-- Name: udx_tCountries_Code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tCountries"
    ADD CONSTRAINT "udx_tCountries_Code" UNIQUE ("Code");


--
-- Name: udx_tDrugsCompanies_Code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugsCompanies"
    ADD CONSTRAINT "udx_tDrugsCompanies_Code" UNIQUE ("Code");


--
-- Name: udx_tDrugsNames_Code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tDrugsNames"
    ADD CONSTRAINT "udx_tDrugsNames_Code" UNIQUE ("Code");


--
-- Name: udx_tExaminationsNamesCategories_Code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsNamesCategories"
    ADD CONSTRAINT "udx_tExaminationsNamesCategories_Code" UNIQUE ("Code");


--
-- Name: udx_tExaminationsNames_Code; Type: CONSTRAINT; Schema: public; Owner: -; Tablespace: 
--

ALTER TABLE ONLY "tExaminationsNames"
    ADD CONSTRAINT "udx_tExaminationsNames_Code" UNIQUE ("ID_ExaminationNameCategory", "Code");


--
-- Name: idx_tDocuments_Person; Type: INDEX; Schema: public; Owner: -; Tablespace: 
--

CREATE INDEX "idx_tDocuments_Person" ON "tDocuments" USING btree ("ID_Person");


--
-- Name: fk_tAdmissions_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAdmissions"
    ADD CONSTRAINT "fk_tAdmissions_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tAdmissions_tHospitalsWards; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAdmissions"
    ADD CONSTRAINT "fk_tAdmissions_tHospitalsWards" FOREIGN KEY ("ID_Hospital", "ID_HospitalWard") REFERENCES "tHospitalsWards"("ID_Hospital", "ID_Ward") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tAdmissions_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAdmissions"
    ADD CONSTRAINT "fk_tAdmissions_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tAllergies_tAllergiesReactions; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAllergies"
    ADD CONSTRAINT "fk_tAllergies_tAllergiesReactions" FOREIGN KEY ("ID_AllergyReactions") REFERENCES "tAllergiesReactions"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tAllergies_tAllergiesTo; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAllergies"
    ADD CONSTRAINT "fk_tAllergies_tAllergiesTo" FOREIGN KEY ("ID_AllergyTo") REFERENCES "tAllergiesTo"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tAllergies_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tAllergies"
    ADD CONSTRAINT "fk_tAllergies_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tCountriesCitiesAddresses_tCountriesCities; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountriesCitiesAddresses"
    ADD CONSTRAINT "fk_tCountriesCitiesAddresses_tCountriesCities" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City") REFERENCES "tCountriesCities"("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tCountriesCities_tCountriesSubGroup3; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountriesCities"
    ADD CONSTRAINT "fk_tCountriesCities_tCountriesSubGroup3" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3") REFERENCES "tCountriesSubGroup3"("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tCountriesSubGroup1_tCountries; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountriesSubGroup1"
    ADD CONSTRAINT "fk_tCountriesSubGroup1_tCountries" FOREIGN KEY ("ID_Country") REFERENCES "tCountries"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tCountriesSubGroup2_tCountriesSubGroup1; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountriesSubGroup2"
    ADD CONSTRAINT "fk_tCountriesSubGroup2_tCountriesSubGroup1" FOREIGN KEY ("ID_Country", "ID_SubGroup1") REFERENCES "tCountriesSubGroup1"("ID_Country", "ID_SubGroup1") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tCountriesSubGroup3_tCountriesSubGroup2; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tCountriesSubGroup3"
    ADD CONSTRAINT "fk_tCountriesSubGroup3_tCountriesSubGroup2" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2") REFERENCES "tCountriesSubGroup2"("ID_Country", "ID_SubGroup1", "ID_SubGroup2") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDoctorsTypes_tDoctors; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDoctorsTypes"
    ADD CONSTRAINT "fk_tDoctorsTypes_tDoctors" FOREIGN KEY ("ID_Person") REFERENCES "tDoctors"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDoctorsTypes_tDoctorsTypesCategories; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDoctorsTypes"
    ADD CONSTRAINT "fk_tDoctorsTypes_tDoctorsTypesCategories" FOREIGN KEY ("ID_DoctorTypeCategory") REFERENCES "tDoctorsTypesCategories"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tDoctors_tPersons; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDoctors"
    ADD CONSTRAINT "fk_tDoctors_tPersons" FOREIGN KEY ("ID_Person") REFERENCES "tPersons"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDocuments_tDocumentsFiles; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDocumentsFiles"
    ADD CONSTRAINT "fk_tDocuments_tDocumentsFiles" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDocuments_tPersons; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDocuments"
    ADD CONSTRAINT "fk_tDocuments_tPersons" FOREIGN KEY ("ID_Person") REFERENCES "tPersons"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDrugsNames_tDrugsCompanies; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsNames"
    ADD CONSTRAINT "fk_tDrugsNames_tDrugsCompanies" FOREIGN KEY ("ID_Company") REFERENCES "tDrugsCompanies"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tDrugsPrescriptions_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsPrescriptions"
    ADD CONSTRAINT "fk_tDrugsPrescriptions_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tDrugsPrescriptions_tDrugsNames; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsPrescriptions"
    ADD CONSTRAINT "fk_tDrugsPrescriptions_tDrugsNames" FOREIGN KEY ("ID_DrugName") REFERENCES "tDrugsNames"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tDrugsPrescriptions_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugsPrescriptions"
    ADD CONSTRAINT "fk_tDrugsPrescriptions_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tDrugs_tDrugsNames; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugs"
    ADD CONSTRAINT "fk_tDrugs_tDrugsNames" FOREIGN KEY ("ID_DrugName") REFERENCES "tDrugsNames"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tDrugs_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tDrugs"
    ADD CONSTRAINT "fk_tDrugs_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminationsDateChanges_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsDateChanges"
    ADD CONSTRAINT "fk_tExaminationsDateChanges_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminationsDateChanges_tExaminations; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsDateChanges"
    ADD CONSTRAINT "fk_tExaminationsDateChanges_tExaminations" FOREIGN KEY ("ID_Examination") REFERENCES "tExaminations"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminationsDoctors_tDoctors; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsDoctors"
    ADD CONSTRAINT "fk_tExaminationsDoctors_tDoctors" FOREIGN KEY ("ID_Doctor") REFERENCES "tDoctors"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminationsDoctors_tExaminations; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsDoctors"
    ADD CONSTRAINT "fk_tExaminationsDoctors_tExaminations" FOREIGN KEY ("ID_Examination") REFERENCES "tExaminations"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminationsNames_tExaminationsNamesCategories; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsNames"
    ADD CONSTRAINT "fk_tExaminationsNames_tExaminationsNamesCategories" FOREIGN KEY ("ID_ExaminationNameCategory") REFERENCES "tExaminationsNamesCategories"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminationsProblems_tExaminations; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminationsProblems"
    ADD CONSTRAINT "fk_tExaminationsProblems_tExaminations" FOREIGN KEY ("ID_Examination") REFERENCES "tExaminations"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminations_tDoctors; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tDoctors" FOREIGN KEY ("ID_Doctor") REFERENCES "tDoctors"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminations_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminations_tExaminationsNames; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tExaminationsNames" FOREIGN KEY ("ID_ExaminationName") REFERENCES "tExaminationsNames"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminations_tHospitals; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tHospitals" FOREIGN KEY ("ID_Hospital") REFERENCES "tHospitals"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminations_tHospitalsWards; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tHospitalsWards" FOREIGN KEY ("ID_Hospital", "ID_HospitalWard") REFERENCES "tHospitalsWards"("ID_Hospital", "ID_Ward") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExaminations_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminations_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tExaminsations_tPrescriptions; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExaminations"
    ADD CONSTRAINT "fk_tExaminsations_tPrescriptions" FOREIGN KEY ("ID_Prescription") REFERENCES "tPrescriptions"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExemptions_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExemption"
    ADD CONSTRAINT "fk_tExemptions_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tExemptions_tPersons; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tExemption"
    ADD CONSTRAINT "fk_tExemptions_tPersons" FOREIGN KEY ("ID_Person") REFERENCES "tPersons"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tHospitalsContacts_tContactsTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsContacts"
    ADD CONSTRAINT "fk_tHospitalsContacts_tContactsTypes" FOREIGN KEY ("ID_ContactType") REFERENCES "tContactsTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tHospitalsContacts_tHospitals; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsContacts"
    ADD CONSTRAINT "fk_tHospitalsContacts_tHospitals" FOREIGN KEY ("ID_Hospital") REFERENCES "tHospitals"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tHospitalsParking_tHospitals; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsParking"
    ADD CONSTRAINT "fk_tHospitalsParking_tHospitals" FOREIGN KEY ("ID_Hospital") REFERENCES "tHospitals"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tHospitalsParking_tHospitalsParkingTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsParking"
    ADD CONSTRAINT "fk_tHospitalsParking_tHospitalsParkingTypes" FOREIGN KEY ("ID_ParkingType") REFERENCES "tHospitalsParkingTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tHospitalsWardsContacts_tContactsTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsWardsContacts"
    ADD CONSTRAINT "fk_tHospitalsWardsContacts_tContactsTypes" FOREIGN KEY ("ID_ContactType") REFERENCES "tContactsTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tHospitalsWardsContacts_tHospitalsWards; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsWardsContacts"
    ADD CONSTRAINT "fk_tHospitalsWardsContacts_tHospitalsWards" FOREIGN KEY ("ID_Hospital", "ID_Ward") REFERENCES "tHospitalsWards"("ID_Hospital", "ID_Ward") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tHospitalsWards_tHospitals; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitalsWards"
    ADD CONSTRAINT "fk_tHospitalsWards_tHospitals" FOREIGN KEY ("ID_Hospital") REFERENCES "tHospitals"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tHospitals_tCountriesCitiesAddresses; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tHospitals"
    ADD CONSTRAINT "fk_tHospitals_tCountriesCitiesAddresses" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City", "ID_Address") REFERENCES "tCountriesCitiesAddresses"("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City", "ID_Address") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tLifeDetails_tLife; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeDetails"
    ADD CONSTRAINT "fk_tLifeDetails_tLife" FOREIGN KEY ("ID_Life") REFERENCES "tLife"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tLifeDetails_tLifeTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeDetails"
    ADD CONSTRAINT "fk_tLifeDetails_tLifeTypes" FOREIGN KEY ("ID_LifeType") REFERENCES "tLifeTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tLifeTypes_tLifeTypesCategories; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeTypes"
    ADD CONSTRAINT "fk_tLifeTypes_tLifeTypesCategories" FOREIGN KEY ("ID_LifeTypeCategory") REFERENCES "tLifeTypesCategories"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tLifeTypes_tMeasurementsUnits; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLifeTypes"
    ADD CONSTRAINT "fk_tLifeTypes_tMeasurementsUnits" FOREIGN KEY ("ID_MeasureUnit") REFERENCES "tMeasurementsUnits"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tLife_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tLife"
    ADD CONSTRAINT "fk_tLife_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tMeasurementsDetails_tMeasurements; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurementsDetails"
    ADD CONSTRAINT "fk_tMeasurementsDetails_tMeasurements" FOREIGN KEY ("ID_Measurement") REFERENCES "tMeasurements"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tMeasurementsDetails_tMeasurementsTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurementsDetails"
    ADD CONSTRAINT "fk_tMeasurementsDetails_tMeasurementsTypes" FOREIGN KEY ("ID_MeasurementType") REFERENCES "tMeasurementsTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tMeasurementsTypes_tMeasurementsUnits; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurementsTypes"
    ADD CONSTRAINT "fk_tMeasurementsTypes_tMeasurementsUnits" FOREIGN KEY ("ID_MeasureUnit") REFERENCES "tMeasurementsUnits"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tMeasurements_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tMeasurements"
    ADD CONSTRAINT "fk_tMeasurements_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPatientsPathologies_tPatholiges; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPatientsPathologies"
    ADD CONSTRAINT "fk_tPatientsPathologies_tPatholiges" FOREIGN KEY ("ID_Pathology") REFERENCES "tPathologies"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tPatientsPathologies_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPatientsPathologies"
    ADD CONSTRAINT "fk_tPatientsPathologies_tPatients" FOREIGN KEY ("ID_Person") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPatients_tDoctors; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPatients"
    ADD CONSTRAINT "fk_tPatients_tDoctors" FOREIGN KEY ("ID_Doctor") REFERENCES "tDoctors"("ID_Person") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tPatients_tPersons; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPatients"
    ADD CONSTRAINT "fk_tPatients_tPersons" FOREIGN KEY ("ID_Person") REFERENCES "tPersons"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPersonsContacts_tContactsTypes; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPersonsContacts"
    ADD CONSTRAINT "fk_tPersonsContacts_tContactsTypes" FOREIGN KEY ("ID_ContactType") REFERENCES "tContactsTypes"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tPersonsContacts_tPersons; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPersonsContacts"
    ADD CONSTRAINT "fk_tPersonsContacts_tPersons" FOREIGN KEY ("ID_Person") REFERENCES "tPersons"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPersons_tCountriesCitiesAddresses; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPersons"
    ADD CONSTRAINT "fk_tPersons_tCountriesCitiesAddresses" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City", "ID_Address") REFERENCES "tCountriesCitiesAddresses"("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City", "ID_Address") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPersons_tCountriesCities_Birth; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPersons"
    ADD CONSTRAINT "fk_tPersons_tCountriesCities_Birth" FOREIGN KEY ("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City") REFERENCES "tCountriesCities"("ID_Country", "ID_SubGroup1", "ID_SubGroup2", "ID_SubGroup3", "ID_City") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPresciptions_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPrescriptions"
    ADD CONSTRAINT "fk_tPresciptions_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tPrescriptions_tDoctors; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPrescriptions"
    ADD CONSTRAINT "fk_tPrescriptions_tDoctors" FOREIGN KEY ("ID_Doctor") REFERENCES "tDoctors"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tPrescriptions_tExaminationsNames; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPrescriptions"
    ADD CONSTRAINT "fk_tPrescriptions_tExaminationsNames" FOREIGN KEY ("ID_ExaminationName") REFERENCES "tExaminationsNames"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tPrescriptions_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tPrescriptions"
    ADD CONSTRAINT "fk_tPrescriptions_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tProblemsPositions_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblemsPositions"
    ADD CONSTRAINT "fk_tProblemsPositions_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tProblemsPositions_tProblems; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblemsPositions"
    ADD CONSTRAINT "fk_tProblemsPositions_tProblems" FOREIGN KEY ("ID_Problem") REFERENCES "tProblems"("ID") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tProblems_tDocuments; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblems"
    ADD CONSTRAINT "fk_tProblems_tDocuments" FOREIGN KEY ("ID_Document") REFERENCES "tDocuments"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tProblems_tPathologies; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblems"
    ADD CONSTRAINT "fk_tProblems_tPathologies" FOREIGN KEY ("ID_Pathology") REFERENCES "tPathologies"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tProblems_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tProblems"
    ADD CONSTRAINT "fk_tProblems_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tVaccinationsSteps_tVaccinationsNames; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinationsSteps"
    ADD CONSTRAINT "fk_tVaccinationsSteps_tVaccinationsNames" FOREIGN KEY ("ID_VaccinationName") REFERENCES "tVaccinationsNames"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- Name: fk_tVaccinations_tPatients; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinations"
    ADD CONSTRAINT "fk_tVaccinations_tPatients" FOREIGN KEY ("ID_Patient") REFERENCES "tPatients"("ID_Person") ON UPDATE CASCADE ON DELETE CASCADE;


--
-- Name: fk_tVaccinations_tVaccinationsSteps; Type: FK CONSTRAINT; Schema: public; Owner: -
--

ALTER TABLE ONLY "tVaccinations"
    ADD CONSTRAINT "fk_tVaccinations_tVaccinationsSteps" FOREIGN KEY ("ID_VaccinationStep") REFERENCES "tVaccinationsSteps"("ID") ON UPDATE CASCADE ON DELETE RESTRICT;


--
-- PostgreSQL database dump complete
--

INSERT INTO "tSettings" ("DbVersion") values (1);